/**
 * 
 */
package org.arga.empresa.repository.useradmin;

import javax.persistence.Query;

import org.arga.empresa.model.useradmin.User;
import org.arga.empresa.repository.GenericJpaRepository;
import org.springframework.stereotype.Repository;

/**
 * Implementation of the <code>UserRepository</code> contract using JPA constructs.
 * <p>Notice that this implementation re-uses the <code>GenericJpaRepository</code>
 * generic abstract implementation to provide basic CRUD operations to the 
 * <code>User</code> object.
 * 
 * @author aflores@arga-inc.com
 * @since Dec 27, 2009 8:55:45 PM
 */
@Repository("userRepository")
public class UserRepositoryImpl extends GenericJpaRepository<Long, User> 
                                implements UserRepository {

	/**
	 * {@inheritDoc}
	 */
	@Override
	public User findByUsername(String username) {
		Query query = m_entityManager.createNamedQuery("user.findByUsername");
		query.setParameter("username", username);
		return (User) query.getSingleResult();
	}
}
